﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Data.SqlClient;
using System.Data;
using QL_LichCT.DataLayer;


namespace QL_LichCT.Utilities
{
    class LoginULT
    {
        DataAccessHelper db = new DataAccessHelper();
        public int _checkUserName;

        public int check_UseName(string u)
        {
            using (SqlConnection sc1 = 
                new SqlConnection(@"Server=.\SQLEXPRESS; Database=QLTienLuong; Integrated Security = True"))
            {
                sc1.Open();
                using (SqlCommand command1 = new SqlCommand())
                {
                    command1.CommandType = CommandType.StoredProcedure;
                    command1.Connection = sc1;
                    // DIRECTION :: Input
                    command1.CommandText = "check_UserID";
                    SqlParameter paramter1 = command1.Parameters.Add(u, SqlDbType.SmallInt);
                    paramter1.Direction = ParameterDirection.ReturnValue;
                    command1.ExecuteNonQuery();
                    //The following value is now 6, the number of records inside the table
                    _checkUserName = (int)paramter1.Value;
                }
            }
            return _checkUserName;
        }
    }
}

  